package com.general.campus.servlet;

import java.io.IOException;
import java.util.UUID;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;

/**
 * @ClassName ServerInfoTag
 * @Desc: 服务器信息tag
 * @Author wangxuan
 * @Date: 2021/7/5 20:30
 * @Verson: 1.0
 **/
public class ServerInfoTag extends SimpleTagSupport {

    private String serverName;

    private String requestId;

    public void setServerName(String serverName) {
        this.serverName = serverName;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    @Override
    public void doTag() throws JspException, IOException {
        if(null == serverName || serverName.length()==0){
            serverName = "undertown server";
        }
        if(null == requestId || requestId.length()==0){
            requestId = UUID.randomUUID().toString();
        }
        this.getJspContext().getOut().write(
                "[Server Info]serverName: " + serverName + ", requestId: " + requestId+"\n");
    }
}
